package com.middlegroup.payadmin.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.middlegroup.payadmin.mapper.ChannelsMapper;
import com.middlegroup.payadmin.pojo.dto.DataGrid;
import com.middlegroup.payadmin.pojo.po.Bank;
import com.middlegroup.payadmin.pojo.po.Channels;
import com.middlegroup.payadmin.service.ChannelsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 通道表 服务实现类
 * </p>
 *
 * @author pc123
 * @since 2019-01-04
 */
@Service
public class ChannelsServiceImpl extends ServiceImpl<ChannelsMapper, Channels> implements ChannelsService {

    @Resource
    private ChannelsMapper channelsMapper;

    @Override
    public PageInfo<Channels> listChannels(DataGrid grid, String name, Long serviceType) {
        grid.getOrderBy();
        return PageHelper.startPage(grid.getPageNum(), grid.getPageSize())
                .doSelectPageInfo(() -> this.channelsMapper.listChannels(name,serviceType));
    }

    @Override
    public List<Bank> getChannelBanks(String code) {
        return channelsMapper.getChannelBanks(code);
    }
}
